package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 自媒体素材管理
 */
@RestController
@RequestMapping("/api/v1/material")
@Slf4j
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 上传图片
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        log.info("【执行上传图片功能】");
        return wmMaterialService.uploadPicture(multipartFile);
    }
    /**
     * 图片素材查询
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto wmMaterialDto){
        log.info("【图片素材查询功能】");
        return wmMaterialService.findList(wmMaterialDto);
    }
    /**
     * 收藏图片素材
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collectPicture(@PathVariable Integer id){
        log.info("【收藏图片素材】");
        return wmMaterialService.collectPicture(id);
    }

    /**
     * 取消收藏图片素材
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult unCollectPicture(@PathVariable Integer id){
        log.info("【取消收藏图片素材】");
        return wmMaterialService.unCollectPicture(id);
    }


    /**
     * 删除图片素材
     * @param id
     * @return
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult deletePicture(@PathVariable Integer id){
        log.info("【删除图片素材】");
        return wmMaterialService.deletePicture(id);
    }



}
